package TestSession;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/code1")
public class Testcode1 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("code1");
        HttpSession session = req.getSession();
        session.setAttribute("admin","hy");
        session.setAttribute("admin2","HY");
        System.out.println("session.getAttribute(\"admin\") = " + session.getAttribute("admin"));
        System.out.println("session.getAttribute(\"admin2\") = " + session.getAttribute("admin2"));
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
       this.doGet(req,resp);
    }
}
